;(function ($) {
	$.tankBattles = $.tankBattles || {};

	/*var key = {
		left:  37,
		up:    38,
		right: 39,
		down:  40,
		fire:  32
	};*/

	var key = {
		left:  65,    // a
		up:    87,    // w
		right: 68,    // d
		down:  83,    // s
		fire:  32     // f - 70
	},
	direction = $.tankBattles.enum.direction,
	attachHandlers = function (player, dt, keysDown) {
		if (key.up in keysDown) {
			player.y -= player.speed * dt;
			player.direction = direction.up;
		} 
		else if (key.left in keysDown) {
			player.x -= player.speed * dt;
			player.direction = direction.left;
		}
		else if (key.right in keysDown) {
			player.x += player.speed * dt;
			player.direction = direction.right;
		}
		else if (key.down in keysDown) { 
			player.y += player.speed * dt;
			player.direction = direction.down;
		}

		// Player is pressing fire button
		if (key.fire in keysDown){
			player.fire();
		}
	};

	$.tankBattles.player = {
	    move: function (dt, keysDown) {
	        var player = this;
			attachHandlers(player, dt, keysDown);
		}
	}
})(epam = typeof epam !== "undefined" ? epam : {});
